<template>
  <el-table :data="detail.list" style="width: 100%">
    <h2>我的工作安排</h2>
    <el-table-column label="ID" prop="id" />
    <el-table-column label="我的工作" prop="planName" />
    <el-table-column label="用户ID" prop="userId" />
    <el-table-column label="用户名" prop="username" />
    <el-table-column label="植物名" prop="plantName" />
  </el-table>
  <el-pagination  v-if="this.detail.total > 5"
    v-model:currentPage="detail.pageNum"
    v-model:page-size="detail.pageSize"
    :total="detail.total"
    :page-sizes="[5, 10]"
    :small="small"
    :background="background"
    layout="total, sizes, prev, pager, next, jumper"
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
  ></el-pagination>
</template>

<script>
export default {
  name: "treework",
  data() {
    return {
      plan: {},
      detail: [
        {
          list: [],
          total: 0,
          pageNum: 0,
          pageSize: 0,
        },
      ],
      user: {},
    };
  },
  methods: {
    handleSizeChange(size) {
      this.detail.pageSize = size;
      this.mount();
    },
    handleCurrentChange(num) {
      this.pageNum = num;
      this.mount();
    },
    mount() {
      this.$axios({
        method: "post",
        url: "http://localhost:8080/nav/accendant/jobtwo",
        data:
          this.$qs.stringify(this.user) +
          "&" +
          this.$qs.stringify({
            pageSize: this.detail.pageSize,
            pageNum: this.detail.pageNum,
          }),
      }).then((res) => {
        console.log(res.data);
        this.project2 = res.data;
        if (res.data.code == 1) {
          this.detail.list = res.data.data.list;
          this.detail.pageSize = res.data.data.pageSize;
          this.detail.pageNum = res.data.data.pageNum;
          this.detail.total = res.data.data.total;
        } else {
          console.log("error");
        }
      });
    },
  },
  mounted() {
    this.user = this.$store.state.user;
    this.mount();
  },
};
</script>

<style scoped>
.el-descriptions {
  margin-top: 20px;
}
.cell-item {
  display: flex;
  align-items: center;
}
.margin-top {
  margin-top: 20px;
}
</style>